import unittest
from parameterized import parameterized
from api.UserService import UserService
from common.r_json import us_findusername


class Test_itheima_US(unittest.TestCase):
    """
    对管理员服务的测试
    """
    ms = None

    @classmethod
    def setUpClass(cls) -> None:
        cls.ms = UserService()

    @parameterized.expand(us_findusername)
    def test01_findByUsername(self, data, asser):
        """
        :param data:搜索的管理员名称
        :param asser: 断言数据
        :return: None
        """
        resp = self.ms.findByUsername(data)
        if resp is not None:
            # 当返回不为空的时候执行
            self.assertEqual(asser, resp.get("username"))
        else:
            # 当返回为空的时候执行
            self.assertEqual(asser, resp)
